package dc.connectionmanager.persistance;

public abstract class AConnection implements IConnection 
{
	protected long lastAction;
	protected boolean busy;
	
	protected String ipAdress;
	protected String username;
	protected String password;
	
	public AConnection(String nIPAdress, String nUsername, String nPassword)
	{
		this.ipAdress = nIPAdress;
		this.username = nUsername;
		this.password = nPassword;
		this.setLastAction();
	}
	

	@Override
	public abstract boolean connect();

	@Override
	public abstract boolean isConnected();

	@Override
	public abstract void closeConnection();

	@Override
	public abstract Object sendCommand(String command);

	@Override
	public abstract void sendCommandNC(String command);

	@Override
	public boolean isBusy() 
	{
		return busy;
	}

	@Override
	public void setLastAction() 
	{
		lastAction = System.currentTimeMillis() / 1000;

	}

	@Override
	public long getIdleTime() 
	{
		return (System.currentTimeMillis() / 1000) - lastAction;
	}

}
